//
//  SYSoundTool.m
//  ARC和MRC状态下的单例分析
//
//  Created by zhouguodong on 15/4/4.
//  Copyright (c) 2015年 shuanyuan. All rights reserved.
//

#import "SYSoundTool.h"

@implementation SYSoundTool
// 保存唯一的实例
static id instace;

// 保证实例对象仅被开辟一次内存空间
+(instancetype)allocWithZone:(struct _NSZone *)zone
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
     instace =  [super allocWithZone:zone];
    });
    return instace;
}

// 对外的统一访问接口,保证仅初始化一次
+(instancetype)sharedSoundTool
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instace = [[self alloc]init];
    });
    return instace;
}

// 保证copy操作创建对象的唯一性
-(id)copyWithZone:(NSZone *)zone
{
    return instace;
}

#pragma MRC 状态下的单例分析
- (oneway void)release
{
    
}
- (instancetype)autorelease
{
    return self;
}
-(instancetype)retain
{
    return self;
}



@end
